<h1><%=TOURNAMENT_TITLE%></h1>

<% if Pool.active_pools.size > 0 %>
<% Pool.active_pools.each do |pool| -%>
<div class="poollistblock">
<span class="poollisthead<%= pool.completed? ? ' poollistheaddone' : ''%>"><%= pool.name %></span>
<small>
<% if current_user && pool.user_id == current_user.id %>
<% if pool.tournament_entry -%>
<%= link_to '[Tourny Results]', :controller => 'admin', :action => 'bracket', :id => pool.id %>
<% end -%>
<%= link_to '[Recap]', :controller => 'admin', :action => 'recap', :id => pool.id%>
<%= link_to '[Edit]', :controller => 'admin', :action => 'pool', :id => pool.id %>
<%= link_to '[Entries]', :controller => 'admin', :action => 'entries', :id => pool.id %>
<% else %>
<% if pool.tournament_entry -%>
<%= link_to '[Tourny Results]', :controller => 'entry', :action => 'show', :id => pool.tournament_entry.id %>
<% end %>
<% end %>
<%= link_to '[Leader Board]', :controller => 'reports', :action => 'show', :id => pool.id, :report => 'leader' %>
<% if has_stats_file(pool.id) -%>
<%= link_to '[Possibilities]', :controller => 'reports', :action => 'show', :id => pool.id, :report => 'possibility' %>
<% end -%>
<%= link_to '[Reports]', :controller => 'reports', :action => 'show', :id => pool.id %>
</small>
<div class="poollistinfo">
<div class="poollistinfodetail">
<% if pool.starts_at < Time.zone.now %>Started<%else%>Starts<%end%>: <%= distance_of_time_in_words(pool.starts_at, Time.now)%>
<% if pool.starts_at < Time.zone.now %>ago.<%else%>from now.<%end%>
Pending Entries: <%= pool.pending_entries.size%>
Total Entries: <%= pool.user_entries.size%>
</div>
<div class="poollistinfodetail">
Last Update: <%=pool.updated_at.to_formatted_s(:long)%>
</div>
<div class="poollistinfodetail">
Entry Fee: <%=number_to_currency(pool.fee)%>
</div>
<% if pool.user_entries.size > 0 -%>
<div class="poollistinfodetail">
Payouts:
<% take = pool.user_entries.size * pool.fee.to_f -
         (pool.payouts.inject(0) {|sum, p| sum += p.kind == '$' ? p.payout.to_i : 0}) %>
<% pool.payouts.delete_if{|p| p.kind.blank?}.sort_by {|p| p.rank }.each do |p| -%>
<%=p.rank != 'L' ? p.rank.to_i.ordinal : 'Last'%>: <%=number_to_currency(p.kind == '$' ? p.payout : p.payout.to_f / 100.0 * take)%>&nbsp;&nbsp;
<% end -%>
</div>
<% end -%>
<div class="poollistinfodetail">
Scoring: <%=pool.pool.scoring_strategy.description%>
</div>
<div class="poollistinfodetail">
<% if current_user -%>
Entries for <%= current_user.login%>: <%= link_to pool.entries_for(current_user).size, :controller => 'entry', :action => 'index', :id => pool.id %>
<% if pool.accepting_entries? -%>
<%= link_to 'Add New Entry', :controller => 'entry', :action => 'new', :id => pool.id %>
<% end -%>
<br/>
<% else -%>
<i>To enter this pool, please <%= link_to 'login', login_path%> or <%= link_to 'signup', signup_path%></i>
<% end -%>
</div>
</div>
</div>
<% end -%>
<% else -%>
<div>
There are no active pools.  Please come back in a bit or contact
an administrator.
</div>
<% end -%>
